

import 'package:flutter/material.dart';
import 'package:flutter_application_demo/second.dart' ;


import 'package:flutter_application_demo/third.dart';


void main() {
  runApp(const MyApp(

  ));
}

//无状态,StatelessWidget因为是无状态的，所以它只会根据初始传入的配置信息来构建Widget，因为Widget是不可变的，所以StatelessWidget创建出来就不会再变化
class MyApp extends StatelessWidget {



  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
      //   home: Scaffold(
      //     appBar: AppBar(
      //
      //       backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      //       title: const Text("111111"),
      //     ),
          // body:const Row(
          //   children: [
          //     Text('aaaaa'),
          //     Text('bbbbbb'),
          //     Row(
          //       mainAxisAlignment: MainAxisAlignment.center,
          //       children: [
          //         Text("ccccccccccc"),
          //         Text("ccccccccccc")
          //       ],
          //     ),
          //     Center(
          //       child: ,
          //     )
          //   ],
          //
          // ),

    );
  }
}

//有状态
/**
 * 创建一个 stateful widget 需要 两个分别extends于StatefulWidget、State的类
 * state对象包含了widget的state和build方法
 */
//除了根据初始传入的配置来创建Widget之外，它内部还包含了一个State。这个State用来和用户的行为进行交互，
// 从而对State中的值进行修改。当State被修改后，和其绑定的Widget会根据特定的算法进行比较，看是否需要进行重绘，从而将用户的交互反映在用户界面上
class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

//widget的state改变的时候，调用setstate方法，框架会重新渲染
class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;



   _goNext(BuildContext context) {
    print("=========");

  }

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(

        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),

      // body: Center(
      //   child: Column(
      //     mainAxisAlignment: MainAxisAlignment.center,
      //     children: <Widget>[
      //       const Text(
      //         'You have pushed the button this many times:',
      //       ),
      //       const Text('lalalala'),
      //       Text(
      //         '点击次数==''$_counter',//此处的文本拼接
      //         style: Theme.of(context).textTheme.headlineMedium,
      //       ),
      //     ],
      //   ),
      // ),
      body: Column(
        mainAxisAlignment:MainAxisAlignment.center,

        children: <Widget>[
          Row(
            children: [
              Image.network(
                "https://img0.baidu.com/it/u=1309980735,2303912522&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800",
                width: 120,
                height: 120,

              ),
              Image.network(
                "https://img.zcool.cn/community/013f4a58b916eba801219c774dd809.jpg@3000w_1l_0o_100sh.jpg",
                width: 120,
                height: 120,
              ),
              Image.asset(
                "images/aaa.jpg",
                width: 120,
                height: 120,
              ),
            ],
          ),

          //是一个结合了绘制（painting）、定位（positioning）以及尺寸（sizing）widget的widget
          //最里层的是child元素,child元素首先会被padding包着
          //
          //容器
          Container(
            // constraints: const BoxConstraints.expand(
            //   width: 120,
            //   height: 120,
            // ),
            // color: Colors.red,
            // margin: const EdgeInsets.only(left: 150, top: 100, right: 30),
            // child: Row(
            //   children: [
            //     Image.network(
            //       "https://img0.baidu.com/it/u=1309980735,2303912522&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800",
            //
            //     )
            //   ],
            // ),
            child: Row(
              children: [
                Image.network(
                  "https://img0.baidu.com/it/u=1309980735,2303912522&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800",
                  width: 120,
                  height: 120,
                ),
                const CircleAvatar(
                  radius: 20,//根据圆角度数变化大小
                  backgroundImage: NetworkImage(
                    "https://img.zcool.cn/community/013f4a58b916eba801219c774dd809.jpg@3000w_1l_0o_100sh.jpg",
                  ),
                )
              ],
            ),

          ),
          // Row(
          //   children: [
          //     Text(
          //         '点击次数==''$_counter',//此处的文本拼接
          //         style: Theme.of(context).textTheme.headlineMedium,
          //     )
          //   ],
          // )
        ],
      ),


      floatingActionButton: FloatingActionButton(
        onPressed: () {
          // setState(() {
          //   _counter++;
          // });

          // Navigator.of(context).push(MaterialPageRoute(
          //     //builder: (context) => const SecondRoute()
          //   builder: (context) => const SecondHomePage()
          // ));

          //third

          Navigator.of(context).push(MaterialPageRoute(
            //builder: (context) => const SecondRoute()
            builder: (context) => const SecondHomePage()
            //builder: (context) => const ThirdHomePage()
          ));

        },
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

class SecondRoute extends StatelessWidget {
  const SecondRoute({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Second Route'),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            // Navigate back to first route when tapped.
            Navigator.pop(context);
          },
          child: const Text('Go back!'),
        ),
      ),
    );
  }
}
